{extend name="./app/admin/view/main.html" /}
{block name="title"}系统设置 - {__block__}{/block}
{block name="style"}
<style>

</style>
{/block}

{block name="main"}
<header class="mipcms-container-header">
    <div class="float-left header-group">
        <h4 class="title">设置</h4> <h5 class="sub-title">系统设置</h5>
    </div>
    <button type="button" class="pull-right ivu-btn ivu-btn-primary ivu-btn-circle" @click='onSubmitSetting'>
        <span>立即保存</span>
    </button>
</header>

<main class="mipcms-container-body" style="height: calc(100% - 50px)">
    <section class="mip-box">
        <section class="mip-box-heading">
            <h3>网站配置</h3>
        </section>
        <section class="mip-box-body">
            <div class="row">
                <div class="col-md-12">
                    <i-form label-position="top">
                        <div class="row">
                            <div class="col-md-2">
                                <Form-item label="站点状态【systemStatus】">
                                    <i-switch v-model="setting.systemStatus">
                                        <span slot="open">开</span>
                                        <span slot="close">关</span>
                                    </i-switch>
                                </Form-item>
                            </div>
                        </div>
                    </i-form>
                </div>
            </div>
        </section>
    </section>

    <section class="mip-box">
        <section class="mip-box-heading">
            <h3>基本设置</h3>
        </section>
        <section class="mip-box-body">

            <i-form label-position="top" class="col-12">
                <div class="row">

                    <Form-item label="网站名称【siteName】" class="col-xl-3 col-md-6">
                        <i-input v-model="setting.siteName" placeholder="例：平步科技"></i-input>
                    </Form-item>
                    <Form-item label="合法域名【legalSiteUrl】，多个域名以 | 分割" class="col-xl-6 col-md-9 ">
                        <i-input v-model="setting.legalSiteUrl" placeholder="例：www.abc.com|www.888.com"></i-input>
                    </Form-item>

                </div>

            </i-form>
        </section>
    </section>

    <section class="mip-box">
        <section class="mip-box-heading">
            <h3>关键词描述</h3>
        </section>
        <section class="mip-box-body">
            <div class="row">
                <div class="col-md-6">
                    <i-form label-position="top">
                        <div class="row">
                            <Form-item label="首页标题【indexTitle】" class="col-6 col-md-12">
                                <i-input v-model="setting.indexTitle" placeholder="国内最大的互联网创业交流社区"></i-input>
                            </Form-item>
                            <Form-item label="网站关键词【keywords】" class="col-6 col-md-12">
                                <i-input type="textarea" v-model="setting.keywords"></i-input>
                            </Form-item>
                            <Form-item label="网站描述【description】" class="col-6 col-md-12">
                                <i-input type="textarea" v-model="setting.description"></i-input>
                            </Form-item>
                        </div>
                    </i-form>
                </div>
            </div>
        </section>
    </section>

    <section class="mip-box">
        <section class="mip-box-heading">
            <h3>微信公众号</h3>
        </section>
        <section class="mip-box-body">

            <i-form label-position="top" class="col-12">
                <div class="row">
                <Form-Item label="AppId【wx_appid】" class="col-xl-3 col-md-6">
                    <i-input v-model="setting.wx_appid"></i-input>
                </Form-Item>
                <Form-Item label="AppSecret【wx_appsecret】" class="col-xl-3 col-md-6">
                    <i-input v-model="setting.wx_appsecret"></i-input>
                </Form-Item>
                </div>
            </i-form>
        </section>
    </section>


</main>
{/block}

{block name="javascript"}
{__block__}
<script type="text/javascript">

</script>

<script>
    var vm = new Vue({
        el: '#app',
        data: {
            authInfo: window.authInfo,
            setting: '',
            codeDemo: '02890d4a309827eb62bc3335b2b28f7f',
        },
        watch: {

        },
        mounted() {
            this.getSettingData();
        },
        methods: {
            onSubmitSetting: function () {
                var _this = this;
                this.$mip.ajax('{$mipInfo.domain}/setting/ApiAdminSetting/do_edit', {
                    setting: JSON.stringify(this.setting),
                }).then(function (res) {
                    if (res.code == 1) {
                        _this.$Message.success('保存成功');
                        setTimeout(function () {
                            window.location.href = '{$mipInfo.domain}/{$Think.config.admin}/setting/setting/';
                        }, 200);
                    }
                });
            },

            getSettingData: function () {
                var _this = this;
                this.loading = true;
                this.$mip.ajax('{$mipInfo.domain}/setting/ApiAdminSetting/get_map', {}).then(function (res) {
                    _this.loading = false;
                    if (res.code == 1) {
                        var temp = res.data;
                        if (temp.systemStatus) {
                            temp.systemStatus = true;
                        } else {
                            temp.systemStatus = false;
                        }

                        _this.setting = temp;
                    }
                });
            },

        }
    })

</script>

{/block}